﻿using Inovout.Repositories;
using NHibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NHibernate.Linq;
namespace Inovout.Security.Repositories
{
    public class PermissionRepository : DataObjectRepository<Permission>
    {
        public IList<Permission> FindByActor(IActor actor)
        {
            ISession session = base.OpenSession();
            return session.Query<Permission>().Where(p => p.Actor == actor).ToList();
        }

        public Permission FindByActorAndPrivilege(IActor actor,Privilege privilege)
        {
            ISession session = base.OpenSession();
            return Single(session.Query<Permission>().Where(p => p.Actor == actor && p.Privilege == privilege).ToList());
        }
    }
}
